package com.longway.core.ext.excel;

import java.util.ArrayList;
import java.util.List;

final public class ExcelHandlers {
	
	private static final List<ExcelHandler> handlerList = new ArrayList<ExcelHandler>();
	
	public ExcelHandlers add(ExcelHandler excelHandler){
		if (excelHandler == null) {
			throw new IllegalArgumentException("excelHandler can not be null");
		}
		handlerList.add(excelHandler);
		return this;
	}
	
	public static ExcelHandler getHandler() {
		ExcelHandler result = handlerList.get(0);
		for (int i=handlerList.size()-1; i>=0; i--) {
			ExcelHandler temp = handlerList.get(i);
			temp.next = result;
			result = temp;
		}
		return result;
	}
}
